package com.atguigu.exam.exception;

import com.atguigu.exam.common.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    //捕获所有异常
    @ExceptionHandler(value =  Exception.class)
    public Result doResolveException(Exception e){
        log.error("服务器异常:{}" ,e.getMessage());
        return Result.error(e.getMessage());
    }
}
